package com.apes.fn.business.fixedLoss.modle;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.crm.business.model.InsuranceCompany;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.plugin.soe.metadata.BusinessAttributeValue;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @program:
 * @description: 定损报表明细
 * @author: lws
 * @create: 2022/10/17 9:58
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = LossQuotationReportItem.CONST_TABLE_NAME)
public class LossQuotationReportItem extends Model {
    public final static String CONST_TABLE_NAME = "ser_loss_quotation_report_item";

    @Id
    @Column(name = "id", nullable = false, length = 8)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "定损报表明细编码")
    @Comment("定损报表明细编码")
    private String id;

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "statistic_Date")
    @Comment("统计日期")
    private Date statisticDate;

    @ManyToOne(optional = false)
    @JoinColumn(name = "loss_Quotation_report_id", referencedColumnName = "id")
    @Comment("定损跟踪报表单号")
    private LossQuotationReport lossQuotationReport;

    @Column(name = "car_Number", length = 16)
    @Comment("车牌号码")
    private String carNumber;

    @Column(name = "retail_order_id",length = 32)
    @Comment("零售单号")
    private String retailOrderId;

    @Column(name = "loss_quotation_id",length = 32)
    @Comment("定损单号")
    private String lossQuotationId;

    @Column(name = "car_accident_id",length = 32)
    @Comment("车险报案单号")
    private String carAccidentId;

    @Column(name = "report_number", length = 64)
    @Comment("报案号")
    private String reportNumber;

    @Comment("案件类型")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "case_type", referencedColumnName = "id")
    private Enumeration caseType;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "business_Staff", referencedColumnName = "id")
    @Comment("商务员工")
    private PartyRole businessStaff;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fixed_Loss_Dept", referencedColumnName = "id")
    @Comment("定损门店")
    private Dept fixedLossDept;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "get_Car_Dept", referencedColumnName = "id")
    @Comment("接车门店")
    private Dept getCarDept;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "insurance_company_id", referencedColumnName = "id")
    @Comment("保险公司")
    private InsuranceCompany insuranceCompany;

    @Comment("定损类型")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "order_Type",  referencedColumnName = "id")
    private BusinessAttributeValue orderType;
}
